﻿using BigfootDNN.Mvc;
using YourCompany.Modules.MvcTemplate.Model;

namespace YourCompany.Modules.MvcTemplate.ViewModel
{
    public class EditTimeEntryViewModel
    {
        public TimesheetItem Entry { get; set; }

        public static EditTimeEntryViewModel Create(int itemId, RouteInfo route)
        {
            var vm = new EditTimeEntryViewModel();
            vm.Entry = route.App.DB.SQL.SELECT("ItemId, ItemDate, Description, Hours").
                                          FROM("{{timesheet}}").
                                          WHERE("ItemID", itemId).
                                          ExecuteObject<TimesheetItem>();
            return vm;
        }
    }
}